{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ac720f38",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4}\n",
      "[1, 2, 3, 2, 4]\n"
     ]
    }
   ],
   "source": [
    "a = [1,2,3,2,4]\n",
    "print(set(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "adfcfca6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[4, 2, 3, 2, 1]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import random \n",
    "random.shuffle(a)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "503c6f3f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入1\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "s = input('输入')\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e1fb1748",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_66188\\1074321261.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[0mb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;36m9\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      8\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "i = input()\n",
    "\n",
    "b = []\n",
    "c=list()\n",
    "for x in i:\n",
    "    b.append(str((int(x)+3)%9))\n",
    "b[0],b[2] = b[2],b[0]\n",
    "b[1],b[3] = b[3],b[1]\n",
    "print(''.join(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "015b711c",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = input().split()\n",
    "a1 = int(s[0])\n",
    "a2 = int(s[1])\n",
    "\n",
    "print(a1 and a2)\n",
    "print(a1 or a2)\n",
    "print(not a1)\n",
    "print(not a2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "e03f2adb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "for line in sys.stdin:\n",
    "    a = line.split()\n",
    "    print(int(a[0]) + int(a[1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "7f6de8bb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 0, 1]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=[0,1]\n",
    "a*2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "19043222",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "Generator expression must be parenthesized (3083177894.py, line 4)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_66188\\3083177894.py\"\u001b[1;36m, line \u001b[1;32m4\u001b[0m\n\u001b[1;33m    a = list(map(lambda x: i * n for i in x, list))\u001b[0m\n\u001b[1;37m                 ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m Generator expression must be parenthesized\n"
     ]
    }
   ],
   "source": [
    "n = int(input())\n",
    "\n",
    "list = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]\n",
    "a = list(map(lambda x: i * n for i in x, list))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "1647f129",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "[1, 2, 3]\n",
      "[2, 2, 3]\n",
      "[2, 2, 3]\n",
      "[2, 4, 3]\n",
      "[2, 4, 3]\n",
      "[2, 4, 6]\n",
      "[4, 5, 6]\n",
      "[8, 5, 6]\n",
      "[8, 5, 6]\n",
      "[8, 10, 6]\n",
      "[8, 10, 6]\n",
      "[8, 10, 12]\n",
      "[7, 8, 9]\n",
      "[14, 8, 9]\n",
      "[14, 8, 9]\n",
      "[14, 16, 9]\n",
      "[14, 16, 9]\n",
      "[14, 16, 18]\n"
     ]
    }
   ],
   "source": [
    "l = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]\n",
    "n = int(input())\n",
    "def c(x):\n",
    "    for i in range(len(x)):\n",
    "        x[i] = x[i]*n\n",
    "    return x\n",
    "\n",
    "a = list(map(c,l))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "be15f1a7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NiuNiulikesNiuMeiButNiumeidontknow\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'N'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_66188\\3268728416.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m     \u001b[1;32mif\u001b[0m \u001b[0md\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      7\u001b[0m         \u001b[0md\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0md\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      8\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'N'"
     ]
    }
   ],
   "source": [
    "s = input()\n",
    "\n",
    "d = {}\n",
    "\n",
    "for i in range(len(s)):\n",
    "    if d[s[i]] > 0:\n",
    "        d[s[i]] = d[s[i]] + 1\n",
    "    else:\n",
    "        d[s[i]] = 1\n",
    "\n",
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "9bcaef22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 8, 14]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "8f7fa824",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "cannot unpack non-iterable int object",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_66188\\2449581746.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mm\u001b[0m \u001b[1;32min\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mm\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: cannot unpack non-iterable int object"
     ]
    }
   ],
   "source": [
    "for i,m in a:\n",
    "    print(i,m)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "9a55e81b",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'N'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_66188\\2292913276.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0md\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0md\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'N'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m: 'N'"
     ]
    }
   ],
   "source": [
    "d = {}\n",
    "d['N']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "8a356b25",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.1\n",
      "3.1\n"
     ]
    }
   ],
   "source": [
    "s = float(input())\n",
    "\n",
    "print(round(s, 2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "2f4c02af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 2\n",
      "3 4\n",
      "(4,6)\n",
      "(-2,-2)\n"
     ]
    }
   ],
   "source": [
    "class Coordinate:\n",
    "    def __init__(self, x, y) -> None:\n",
    "        self.x = x\n",
    "        self.y = y\n",
    "    \n",
    "    def __str__(self) -> str:\n",
    "        return \"({},{})\".format(self.x, self.y)\n",
    "\n",
    "    def __add__(self, s2):\n",
    "        return Coordinate(self.x + s2.x, self.y+s2.y)\n",
    "    \n",
    "    def __sub__(self, other):\n",
    "        return Coordinate(self.x - other.x, self.y - other.y)\n",
    "\n",
    "x1, y1 = list(map(int, input().split()))\n",
    "x2, y2 = list(map(int, input().split()))\n",
    "\n",
    "c1 = Coordinate(x1, y1)\n",
    "c2 = Coordinate(x2, y2)\n",
    "\n",
    "print(c1+c2)\n",
    "print(c1-c2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "9458e119",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dhttps://www.Nowcoder.com\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "url = input()\n",
    "\n",
    "print(re.match(r\"https://www\", url))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "884fd4df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2 2 2 2]\n",
      "2020-02-01 2 days 2020-02-03\n",
      "[numpy.datetime64('2020-02-01'), numpy.datetime64('2020-02-02')]\n",
      "2020-02-03 2 days 2020-02-05\n",
      "[numpy.datetime64('2020-02-01'), numpy.datetime64('2020-02-02'), numpy.datetime64('2020-02-03'), numpy.datetime64('2020-02-04')]\n",
      "2020-02-05 2 days 2020-02-07\n",
      "[numpy.datetime64('2020-02-01'), numpy.datetime64('2020-02-02'), numpy.datetime64('2020-02-03'), numpy.datetime64('2020-02-04'), numpy.datetime64('2020-02-05'), numpy.datetime64('2020-02-06')]\n",
      "2020-02-07 2 days 2020-02-09\n",
      "[numpy.datetime64('2020-02-01'), numpy.datetime64('2020-02-02'), numpy.datetime64('2020-02-03'), numpy.datetime64('2020-02-04'), numpy.datetime64('2020-02-05'), numpy.datetime64('2020-02-06'), numpy.datetime64('2020-02-07'), numpy.datetime64('2020-02-08')]\n",
      "['2020-02-01' '2020-02-02' '2020-02-03' '2020-02-04' '2020-02-05'\n",
      " '2020-02-06' '2020-02-07' '2020-02-08']\n",
      "['2020-02-01' '2020-02-02' '2020-02-03' '2020-02-04' '2020-02-05'\n",
      " '2020-02-06' '2020-02-07' '2020-02-08' '2020-02-09']\n",
      "['2020-02-01' '2020-02-02' '2020-02-03' '2020-02-04' '2020-02-05'\n",
      " '2020-02-06' '2020-02-07' '2020-02-08' '2020-02-09']\n",
      "2020-02-09\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "dates = np.arange('2020-02-01', '2020-02-10', 2, np.datetime64)\n",
    "out = []\n",
    "print(np.diff(dates))\n",
    "for date, d in zip(dates, np.diff(dates)):\n",
    "    print(date, d, date+d)\n",
    "    out.extend(np.arange(date, date + d))\n",
    "    print(out)\n",
    "fillin = np.array(out)\n",
    "print(fillin)\n",
    "output = np.hstack([fillin, dates[-1]])\n",
    "f=np.concatenate((fillin, [dates[-1]]))\n",
    "print(output)\n",
    "print(f)\n",
    "print(dates[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "40b95902",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4, 5, 6])"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "a=[1,2,3]\n",
    "b=[4,5,6]\n",
    "np.concatenate((a,b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "03eefc83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 1])"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.diff([1,2,3,4,5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "0764ac0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0.]])"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.zeros((4,5))\n",
    "a[-1:1,:] = 1\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "4ce7a04d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1, 1],\n",
       "       [1, 0, 0, 1],\n",
       "       [1, 1, 1, 1]])"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = np.full((3,4),1)\n",
    "b[1:-1,1:-1] = 0\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "f6a81a0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ True,  True,  True],\n",
       "       [ True,  True,  True],\n",
       "       [ True,  True,  True]])"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((3,3), dtype=np.bool_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "6586c31d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2023-02-10 2023-02-10\n"
     ]
    }
   ],
   "source": [
    "\n",
    "today = np.datetime64('today', 'D')\n",
    "print(today, str(today))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "5f545b3f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.30000000000000004"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3*0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "3098c487",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[numpy.datetime64('2020-02-01'), numpy.datetime64('2020-02-02'), numpy.datetime64('2020-02-03'), numpy.datetime64('2020-02-04'), numpy.datetime64('2020-02-05'), numpy.datetime64('2020-02-06'), numpy.datetime64('2020-02-07'), numpy.datetime64('2020-02-08')]\n",
      "['2020-02-01' '2020-02-02' '2020-02-03' '2020-02-04' '2020-02-05'\n",
      " '2020-02-06' '2020-02-07' '2020-02-08' '2020-02-09']\n"
     ]
    }
   ],
   "source": [
    "# 求间隔\n",
    "# 根据间隔造数据\n",
    "# 连接数据\n",
    "dates = np.arange('2020-02-01', '2020-02-10', 2, np.datetime64)\n",
    "diff = np.diff(dates)\n",
    "odates = []\n",
    "for d,date in zip(diff,dates):\n",
    "    r = np.arange(date,d, dtype=np.datetime64)\n",
    "    odates.extend(r)\n",
    "m = np.hstack([odates, dates[-1]])\n",
    "print(odates)\n",
    "print(m)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "df372799",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.datetime64('2023-02-13')"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.datetime64('today','D')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "25918e59",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ True,  True,  True],\n",
       "       [ True,  True,  True],\n",
       "       [ True,  True,  True]])"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((3,3),dtype=bool)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "e96804bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = [1,2,3,4]\n",
    "y = x[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "id": "ed5cde58",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4]\n",
      "[0, 2]\n"
     ]
    }
   ],
   "source": [
    "y[0] = 0\n",
    "print(x)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "id": "50e0a803",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 2 3 4]\n",
      "[0 2]\n"
     ]
    }
   ],
   "source": [
    "x = np.array([1,2,3,4])\n",
    "y = x[0:2]\n",
    "y[0] = 0\n",
    "print(x)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "aa1b4a63",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[12 14]\n",
      " [32 34]]\n"
     ]
    }
   ],
   "source": [
    "x = np.array([[11, 12, 13, 14, 15],\n",
    "              [16, 17, 18, 19, 20],\n",
    "              [21, 22, 23, 24, 25],\n",
    "              [26, 27, 28, 29, 30],\n",
    "              [31, 32, 33, 34, 35]])\n",
    "\n",
    "r = np.array([[0, 0], [4, 4]])\n",
    "c = np.array([[1, 3], [1, 3]])\n",
    "y = x[r,c]\n",
    "print(y)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "id": "7649792d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0 1 2]\n",
      " [3 4 5]\n",
      " [6 7 8]]\n",
      "[[6 7 8]\n",
      " [3 4 5]\n",
      " [0 1 2]]\n"
     ]
    }
   ],
   "source": [
    "arr = np.arange(9).reshape(3, 3)\n",
    "print(arr)\n",
    "x = arr[::-1,:]\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "id": "6c61fb04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[array([[11],\n",
       "        [16],\n",
       "        [21]]),\n",
       " array([[12],\n",
       "        [17],\n",
       "        [22]]),\n",
       " array([[13, 14],\n",
       "        [18, 19],\n",
       "        [23, 24]])]"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.array([[11, 12, 13, 14],\n",
    "              [16, 17, 18, 19],\n",
    "              [21, 22, 23, 24]])\n",
    "y = np.hsplit(x, [1, 2])\n",
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "id": "e5b8f315",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2],\n",
       "       [3, 4]])"
      ]
     },
     "execution_count": 172,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.array([[1, 2], [3, 4]])\n",
    "y = np.repeat(x, [1,1], axis=1)\n",
    "y\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 180,
   "id": "af4b07fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([1, 2, 3, 4, 5]),\n",
       " array([0, 2, 3, 5, 7], dtype=int64),\n",
       " array([2, 1, 2, 2, 1], dtype=int64))"
      ]
     },
     "execution_count": 180,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=np.array([1,1,2,3,3,4,4,5])\n",
    "b=np.unique(a,return_counts=True, return_index=True)\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "id": "56598f7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 1, 2, 3, 4],\n",
       "       [5, 6, 7, 8, 9]])"
      ]
     },
     "execution_count": 175,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = np.arange(10)\n",
    "np.reshape(arr, (2,-1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "id": "e506c217",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 1, 2, 3, 4],\n",
       "       [5, 6, 7, 8, 9],\n",
       "       [1, 1, 1, 1, 1],\n",
       "       [1, 1, 1, 1, 1]])"
      ]
     },
     "execution_count": 177,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.arange(10).reshape([2, -1])\n",
    "b = np.repeat(1, 10).reshape([2, -1])\n",
    "np.vstack([a,b])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "id": "b212c3a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 1, 2, 3, 4, 1, 1, 1, 1, 1],\n",
       "       [5, 6, 7, 8, 9, 1, 1, 1, 1, 1]])"
      ]
     },
     "execution_count": 179,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.arange(10).reshape([2, -1])\n",
    "b = np.repeat(1, 10).reshape([2, -1])\n",
    "np.hstack([a,b])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "7d6965a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([16, 11, 21, 31, 26, 17, 12, 22, 32, 27, 18, 13, 23, 33, 28, 19, 14,\n",
       "       24, 34, 29, 20, 15, 25, 35, 30])"
      ]
     },
     "execution_count": 183,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = np.array([[16, 17, 18, 19, 20],[11, 12, 13, 14, 15],[21, 22, 23, 24, 25],[31, 32, 33, 34, 35],[26, 27, 28, 29, 30]])\n",
    "b = arr.flatten(order='F')\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "e84cc3f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False],\n",
       "       [False, False]])"
      ]
     },
     "execution_count": 187,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array([0, 4, 5])\n",
    "a = np.eye(2)\n",
    "a\n",
    "np.isnan(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "76d15111",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "A = np.array([1,2,3])\n",
    "B = np.array([1,2,3])\n",
    "\n",
    "# Assuming identical shape of the arrays and a tolerance for the comparison of values\n",
    "equal = np.allclose(A,B)\n",
    "print(equal)\n",
    "\n",
    "# Checking both the shape and the element values, no tolerance (values have to be exactly equal)\n",
    "equal = np.array_equal(A,B)\n",
    "print(equal)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "1dcbe496",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2 3 4 5 6 7 8 9]\n",
      "[2 3 4 5 6 7 8 9]\n",
      "[1 2 3 4 5 6 7 8]\n"
     ]
    }
   ],
   "source": [
    "x = np.array([1, 2, 3, 4, 5, 6, 7, 8])\n",
    "y = x + 1\n",
    "print(y)\n",
    "print(np.add(x, 1))\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "id": "274598fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10.        , 14.18016912, 25.67851979, 24.39506547, 10.        ,\n",
       "       30.        , 24.75331848, 10.        , 10.        , 17.66233124,\n",
       "       18.69136176, 21.5441475 , 10.        , 21.40962377, 30.        ,\n",
       "       30.        , 30.        , 10.        , 30.        , 18.85960644])"
      ]
     },
     "execution_count": 193,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.random.uniform(1, 50, 20)\n",
    "a\n",
    "b = np.clip(a, a_min=10, a_max=30)\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "id": "96c3ffe4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 2  4 -6  1  4 -6  1]\n",
      "[ 1  1 -1  1  1 -1  1]\n",
      "[ 0 -2  2  0 -2  2]\n",
      "[2 5]\n"
     ]
    }
   ],
   "source": [
    "a = np.array([1, 3, 7, 1, 2, 6, 0, 1])\n",
    "b1 = np.diff(a)\n",
    "b2 = np.sign(b1)\n",
    "b3 = np.diff(b2)\n",
    "\n",
    "print(b1)  # [ 2  4 -6  1  4 -6  1]\n",
    "print(b2)  # [ 1  1 -1  1  1 -1  1]\n",
    "print(b3)  # [ 0 -2  2  0 -2  2]\n",
    "index = np.where(np.equal(b3, -2))[0]+1\n",
    "\n",
    "print(index) # [2 5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "id": "3f1f07b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "z = np.random.randint(10, size=10)\n",
    "np.average?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "1af2bdcd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-1,  6, -4, -1,  6, -4, -2])"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.diff(a[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "id": "383801ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[8 8 3 7 7 0 4 2 5 2]\n",
      "[ 8 16 19 26 33 33 37 39 44 46]\n",
      "a[n:]: [26 33 33 37 39 44 46]\n",
      "a[:-n]: [ 8 16 19 26 33 33 37]\n",
      "[18 17 14 11  6 11  9]\n",
      "[19 18 17 14 11  6 11  9]\n",
      "[6.33 6.   5.67 4.67 3.67 2.   3.67 3.  ]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "np.random.seed(100)\n",
    "z = np.random.randint(10, size=10)\n",
    "print(z)\n",
    "# [8 8 3 7 7 0 4 2 5 2]\n",
    "\n",
    "def MovingAverage(arr, n=3):\n",
    "    a = np.cumsum(arr)\n",
    "    print(a)\n",
    "    print('a[n:]:',a[n:])\n",
    "    print('a[:-n]:',a[:-n])\n",
    "    a[n:] = a[n:] - a[:-n]\n",
    "    print(a[n:])\n",
    "    print(a[n - 1:])\n",
    "    return a[n - 1:] / n\n",
    "\n",
    "\n",
    "r = MovingAverage(z, 3)\n",
    "print(np.around(r, 2))\n",
    "# [6.33 6.   5.67 4.67 3.67 2.   3.67 3.  ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "id": "200cf0ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "Z = np.random.random((5,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 212,
   "id": "6e985a8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.21632535, 0.47325103, 0.91524305, 0.06127262, 0.65493036],\n",
       "       [0.54801839, 0.58926138, 0.        , 0.3193737 , 1.        ],\n",
       "       [0.12795558, 0.07748118, 0.32353513, 0.66347756, 0.73439843],\n",
       "       [0.67362336, 0.9680627 , 0.31032334, 0.59609058, 0.18298724],\n",
       "       [0.55778785, 0.67862832, 0.1442746 , 0.60947883, 0.50125924]])"
      ]
     },
     "execution_count": 212,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "min_ = np.min(Z)\n",
    "max_ = np.max(Z)\n",
    "r = (Z - min_)/(max_-min_)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "id": "979354a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.89006297 7.01487727 3.85572122 0.17422545 0.5096687  4.35071739\n",
      " 9.76843867 0.93783309 5.51519502 6.43103143]\n",
      "[0. 7. 3. 0. 0. 4. 9. 0. 5. 6.]\n",
      "[0. 7. 3. 0. 0. 4. 9. 0. 5. 6.]\n",
      "[0. 7. 3. 0. 0. 4. 9. 0. 5. 6.]\n",
      "[0. 7. 3. 0. 0. 4. 9. 0. 5. 6.]\n",
      "[0 7 3 0 0 4 9 0 5 6]\n"
     ]
    }
   ],
   "source": [
    "Z = np.random.uniform(0,10,10)\n",
    "print(Z)\n",
    "print(np.floor(Z))\n",
    "print(np.ceil(Z)-1)\n",
    "\n",
    "print(Z - Z%1)\n",
    "print(Z//1)\n",
    "C = Z.astype(int)\n",
    "print(C)\n",
    "np.trunc()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 226,
   "id": "2070fe93",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 226,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(5).itemsize"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "id": "351bf81b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[          0           2           4]\n",
      " [          1           3           5]\n",
      " [          2           4           6]\n",
      " [          3           5           7]\n",
      " [          4           6           8]\n",
      " [          5           7           9]\n",
      " [          6           8  -392572103]\n",
      " [          7           9 -1879047936]]\n"
     ]
    }
   ],
   "source": [
    "from numpy.lib import stride_tricks\n",
    "def rolling(a, window):\n",
    "    shape = (a.size - window + 1, window)\n",
    "    strides = (a.itemsize, a.itemsize)\n",
    "    return stride_tricks.as_strided(a, shape=shape, strides=strides)\n",
    "Z = rolling(np.arange(10), 3)\n",
    "print (Z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "id": "a13a1923",
   "metadata": {},
   "outputs": [],
   "source": [
    "Z.mean?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "id": "9e5ff38b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 6,  9, 10])"
      ]
     },
     "execution_count": 246,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array([2, 6, 1, 9, 10, 3, 27])\n",
    "\n",
    "a[np.logical_and(a>=5,a<=10)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "id": "10b184f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 6  9 10]\n"
     ]
    }
   ],
   "source": [
    "x = a[np.logical_and(a >= 5, a <= 10)]\n",
    "print(x)  # [ 6  9 10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "id": "139f671f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['a'], dtype='<U1')"
      ]
     },
     "execution_count": 247,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array(['a'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 248,
   "id": "fb721c56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 4, 29,  6, 19,  7, 18, 11, 14, 18, 22])"
      ]
     },
     "execution_count": 248,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.random.randint(1, 30, 10)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "id": "4d347488",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0., 0., 0.],\n",
       "       [0., 1., 0., 0., 0.],\n",
       "       [0., 0., 1., 0., 0.],\n",
       "       [0., 0., 0., 1., 0.],\n",
       "       [0., 0., 0., 0., 1.]])"
      ]
     },
     "execution_count": 250,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.eye(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "id": "464320e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[3 4 0]\n",
      " [0 4 0]\n",
      " [5 6 0]]\n",
      "(3, 3)\n",
      "2\n",
      "(array([2, 2], dtype=int64), array([0, 1], dtype=int64))\n"
     ]
    }
   ],
   "source": [
    "x = np.array([[3, 4, 0], [0, 4, 0], [5, 6, 0]])\n",
    "print(x)\n",
    "# [[3 0 0]\n",
    "#  [0 4 0]\n",
    "#  [5 6 0]]\n",
    "print(x.shape)  # (3, 3)\n",
    "print(x.ndim)  # 2\n",
    "\n",
    "y = np.nonzero(x>4)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "id": "8ab61db3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 3, 4, 6, 8])"
      ]
     },
     "execution_count": 254,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = np.array([2,4,6,8,3,4])\n",
    "np.unique(arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "id": "8fb41858",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 3 4]\n"
     ]
    }
   ],
   "source": [
    "x = np.array([[1, 1], [4, 3]])\n",
    "u = np.unique(x)\n",
    "print(u)  # [1 2 3]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "id": "61bc697a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 0 0]\n",
      " [1 1 0]\n",
      " [2 3 4]]\n"
     ]
    }
   ],
   "source": [
    "x = np.array([[1, 1, 0], [1, 0, 0], [2, 3, 4]])\n",
    "y = np.unique(x, axis=0)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 262,
   "id": "a28443d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[2 0 0]\n",
      " [9 1 5]\n",
      " [2 3 6]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[2],\n",
       "       [9],\n",
       "       [2]])"
      ]
     },
     "execution_count": 262,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Z = np.random.randint(0,10,(3,3))\n",
    "print(Z)\n",
    "#np.argsort(Z)\n",
    "np.argpartition(Z, kth=2)\n",
    "Z[:,0:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 267,
   "id": "3969384a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[10  6 16]\n",
      " [23 20  5]\n",
      " [28 17 15]\n",
      " [21 21 19]\n",
      " [20  3 22]\n",
      " [ 5 10 27]\n",
      " [11 16 16]\n",
      " [ 6 26 17]]\n",
      "[[ 5  3  5]\n",
      " [ 6  6 15]\n",
      " [10 10 16]\n",
      " [21 21 19]\n",
      " [20 20 22]\n",
      " [28 17 27]\n",
      " [11 16 16]\n",
      " [23 26 17]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 5,  3,  5],\n",
       "       [ 6,  6, 15],\n",
       "       [10, 10, 16]])"
      ]
     },
     "execution_count": 267,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.random.randint(0,30,[8,3])\n",
    "print(a)\n",
    "b = np.partition(a, kth=2, axis=0)\n",
    "print(b)\n",
    "b[0:3,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 268,
   "id": "28cdfea0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 3, 5, 7, 9])"
      ]
     },
     "execution_count": 268,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr = np.arange(10)\n",
    "arr[np.where(arr%2==1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 269,
   "id": "01a37e30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 0, 3, 0, 5, 0, 7, 0, 9])"
      ]
     },
     "execution_count": 269,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "brr = np.where(arr%2==0, 0, arr)\n",
    "brr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 270,
   "id": "32ebb8dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([16.6442524 , 13.90492337, 27.57175006,  5.03096167, 32.14619878,\n",
       "       40.02385603, 47.78262777, 34.54658931, 24.92636517, 24.7853012 ,\n",
       "       48.36795311, 11.35604649, 21.17075877, 49.49361326,  2.39218098,\n",
       "       35.36499919,  2.23340663, 16.72320458,  4.60282603,  3.98334365])"
      ]
     },
     "execution_count": 270,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.random.uniform(1, 50, 20)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 275,
   "id": "47281a6b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([15,  5,  6, 10, 13], dtype=int64)"
      ]
     },
     "execution_count": 275,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.argsort(a)[-5:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 276,
   "id": "f34ff60d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1.,  2.,  3., nan,  5.,  6.,  7., nan])"
      ]
     },
     "execution_count": 276,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array([1, 2, 3, np.nan, 5, 6, 7, np.nan])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 280,
   "id": "8e593afb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1., 2., 3., 5., 6., 7.])"
      ]
     },
     "execution_count": 280,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[np.where(a/1==a)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "id": "535ef62e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 1.98307969  5.2405738   6.3017132  11.35281231 19.97561346 22.0035216\n",
      " 38.5488966  40.95159039 44.77676729 49.7680047 ]\n",
      "3\n",
      "7\n",
      "[ 1.98307969  5.2405738   6.3017132  11.35281231 19.97561346 22.0035216\n",
      " 38.5488966  40.95159039 44.77676729 49.7680047 ]\n",
      "7\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 300,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=np.random.uniform(1, 50, 10)\n",
    "a.sort()\n",
    "print(a)\n",
    "print(np.searchsorted(a,7,side='right'))\n",
    "print(len(a)-np.searchsorted(a,7,side='right'))\n",
    "print(a)\n",
    "print(len(a[np.greater(a,7)])) \n",
    "len(a)-np.searchsorted(a,7,side='right')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 301,
   "id": "acf6b334",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.65451374 0.29728338 0.52388708]\n",
      " [0.5144319  0.67416737 0.10163702]\n",
      " [0.74463003 0.06117886 0.04711474]\n",
      " [0.09895012 0.39248525 0.18000174]\n",
      " [0.48507722 0.71825949 0.32580512]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "np.random.seed(2002)\n",
    "rand_arr = np.random.random([5,3])\n",
    "print(rand_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 305,
   "id": "fc9cf1bd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.3897\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAk0AAAGwCAYAAAC0HlECAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA050lEQVR4nO3df3hU5Z3//9cYyBCzyZEQJ5O5DMhazIKJCAmShFZRbEJKYKm2aHFHstJQy6+yIduC7afFriW0iLorK0VWQRA3Xnsp+AONhKJYFsKP2FQClGILEkpCAJMJoTBJw/n+0fV8HRLwjgVmgs/HdZ3rypz7PWfe5xSvefWee864bNu2BQAAgAu6KtwNAAAAdAeEJgAAAAOEJgAAAAOEJgAAAAOEJgAAAAOEJgAAAAOEJgAAAAM9wt3AleTs2bM6cuSI4uLi5HK5wt0OAAAwYNu2Tp48KZ/P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Ay8z0/btbrGkCAAAIN0ITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAAUITAACAgbCGpvfee09jx46Vz+eTy+XS2rVrQ8YLCwvlcrlCtqysrJCaYDCoGTNmKDExUbGxsRo3bpwOHz4cUtPY2Ci/3y/LsmRZlvx+v5qamkJqDh06pLFjxyo2NlaJiYmaOXOmWltbL8VpAwCAbiisoenUqVMaPHiwFi9efN6a0aNHq66uztnefPPNkPFZs2ZpzZo1Kisr0+bNm9XS0qKCggK1t7c7NRMnTlR1dbXKy8tVXl6u6upq+f1+Z7y9vV1jxozRqVOntHnzZpWVlenll1/W7NmzL/5JAwCAbqlHOF88Pz9f+fn5F6xxu93yer2djgUCAT377LNatWqV7rrrLknSCy+8oJSUFG3YsEF5eXnau3evysvLVVlZqeHDh0uSli1bpuzsbO3bt0+pqalav3699uzZo9raWvl8PknSokWLVFhYqJ/97GeKj4+/iGcNAAC6o4hf0/Tuu+/K4/HoxhtvVFFRkRoaGpyxqqoqtbW1KTc319nn8/mUlpamLVu2SJK2bt0qy7KcwCRJWVlZsiwrpCYtLc0JTJKUl5enYDCoqqqq8/YWDAbV3NwcsgEAgCtTRIem/Px8rV69Whs3btSiRYu0Y8cO3XnnnQoGg5Kk+vp6RUdHq3fv3iHPS0pKUn19vVPj8Xg6HNvj8YTUJCUlhYz37t1b0dHRTk1nSktLnXVSlmUpJSXlbzpfAAAQucL68dxnuffee52/09LSlJmZqX79+mndunW6++67z/s827blcrmcx5/++2+pOdfcuXNVXFzsPG5ubiY4AQBwhYromaZzJScnq1+/ftq/f78kyev1qrW1VY2NjSF1DQ0NzsyR1+vV0aNHOxzr2LFjITXnzig1Njaqra2twwzUp7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ejz322OW9IAAAIGK5bNu2w93ElaK5uVmWZSkQCFz0Garr56y7qMdD5w4uGBPuFgAAl5np+3dEr2kCAACIFIQmAAAAA4QmAAAAA1369lxlZWWXfirk3J8vAQAA6K66FJqmTp2q8ePHy3Tt+Lp160LujwQAANBddSk02batH//4x8b1b7zxRpcbAgAAiERdWtN0od9huxj1AAAAkYqF4AAAAAYITQAAAAa6vKaptrbWaCG4bdvGC8YBAAAiXZdC0+jRo/X973/fuD4vL6/LDQEAAESiLoWm0tLSS9UHAABAROtSaMrNzVVLS4txfe/evbVuHT80CwAAur8uhaZjx47pN7/5jXH9sGHDutwQAABAJOI+TQAAAAa45QAAAIABQhMAAIABQhMAAICBLt/c8s477/zMm1a6XC5ubgkAAK4oXQpN27dv19mzZ43rr7qKiSwAAHBl6FJoWrp0qY4cOWJcf91112nq1KldbgoAACDSdCk0Pffcc3ryySeNP3b713/9V0ITAAC4InR5TdNtt93WpXoAAIArATe3BAAAMMBKbQAAAAOEJgAAAANdXtO0cuVK41rWNAEAgCtFl0LTj370Ix0/fty4/uGHH+5yQwAAAJGoS6Fp2LBhOnPmjHF9TExMlxsCAACIRF0KTePHj9ctt9xi/DMqu3fv1vbt2/+mBgEAACJBl9c0Pffcc8b1w4YN63JDAAAAkYj7NAEAABjglgMAAAAGCE0AAAAGuhSaunrfpc+qf++99zR27Fj5fD65XC6tXbu2w/PnzZsnn8+nmJgYjRw5Urt37w6pCQaDmjFjhhITExUbG6tx48bp8OHDITWNjY3y+/2yLEuWZcnv96upqSmk5tChQxo7dqxiY2OVmJiomTNnqrW1tUvnCwAArlxdWgienp6u7OzsLtVfyKlTpzR48GD98z//s+65554O47/4xS/0+OOPa8WKFbrxxhv16KOP6qtf/ar27dunuLg4SdKsWbP0+uuvq6ysTH369NHs2bNVUFCgqqoqRUVFSZImTpyow4cPq7y8XJI0ZcoU+f1+vf7665Kk9vZ2jRkzRtdee602b96sEydOaNKkSbJtW0899ZTx+QIAgCuXy46Q23a7XC6tWbNG48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JfL5ex/99135fF4dOONN6qoqEgNDQ3OWFVVldra2pSbm+vs8/l8SktL05YtWyRJW7dulWVZTmCSpKysLFmW5dR0prS01Pk4z7IspaSkXMzTBQAAEaRbhaa1a9eqqalJhYWFzr78/HytXr1aGzdu1KJFi7Rjxw7deeedzgxQfX29oqOj1bt375BjJSUlqb6+3qnxeDwdXs/j8Tg1nZk7d64CgYCz1dbWXoSzBAAAkSjiP577tGeffVb5+fny+XzOvnvvvdf5Oy0tTZmZmerXr5/WrVunu++++7zHsm07ZLbq03+fr+Zcbrdbbre7q6cBAAC6oW4z0/TRRx9pw4YN+va3v33BuuTkZPXr10/79++XJHm9XrW2tqqxsTGkrqGhQUlJSU7N0aNHOxzr2LFjTg0AAPhi6zahafny5fJ4PBozZswF606cOKHa2lolJydLkjIyMtSzZ0/nW3eSVFdXp5qaGuXk5EiSsrOzFQgEtH37dqdm27ZtCgQCTg0AAPhi6xYfz509e1bLly/XpEmT1KPH/99yS0uL5s2bp3vuuUfJyck6ePCgHn74YSUmJurrX/+6JMmyLE2ePFmzZ89Wnz59lJCQoJKSEqWnpzvfphs4cKBGjx6toqIiLV26VJI0ZcoUFRQUnPebcwAA4IulW4SmDRs26NChQ3rwwQdD9kdFRWnXrl1auXKlmpqalJycrDvuuEMvvfSS4uLinLonnnhCPXr00IQJE3T69GmNGjVKK1asUFRUlFOzevVqzZw50/mW3bhx47R48eLLc4IAACDiuWzbtsPdxJWiublZlmUpEAgoPj7+oh77+jnrLurx0LmDCy788W8k6q7/NrrjtQZwZTJ9/+42a5oAAADCidAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABgIKJD07x58+RyuUI2r9frjNu2rXnz5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jY2Fj16dOH9XKdKCkp0dixY9W3b181NDTo0UcfVXNzsyZNmhTu1iLOv/zLvygnJ0fz58/XhAkTtH37dj3zzDN65plnLn8zNiLef/7nf9r9+vWzo6Oj7aFDh9qbNm0Kd0sR55133rElddgmTZoU7tYiTmfXSZK9fPnycLcWcR588EHnv71rr73WHjVqlL1+/fpwt9Vt3H777fb3vve9cLcRke699147OTnZ7tmzp+3z+ey7777b3r17d7jbilivv/66nZaWZrvdbvsf/uEf7GeeeSYsfXCfJgAAAAOsaQIAADBAaAIAADBAaAIAADBAaAIAADBAaAIAADBAaAIAADBAaAIAADBAaAIAADBAaAIAADDAb88BiEhbtmzR1KlTOx0bPXq0du7cqePHj3c6vn37dv3yl7/Uc8891+n4j370I2VmZmr8+PGdjt98881auXKlHnjgAX3wwQed1qxdu1Y7d+7Uo48+2un4gw8+qIceeki33nprp+OJiYnasGGD5syZc97fsnv66acl6YLXYcGCBZ2OAbj4CE0AIlJzc7PGjx+vefPmhew/ePCg5syZo5aWFlVXV3d43siRI3X27FkdOXJETz75pEaOHBkyvmLFCh0/flxnzpzRLbfcohUrVnQ4RlZWlqS//pJ6Z69RWFioM2fO6Pjx45o1a5YKCwtDxj/5Ud+zZ8/qmmuu0bvvvnve1zh48KDWrl2r66+/PmR83rx5am5ulqQLXgcAlw8fzwEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABjgZ1QARCTLsvTGG2/ojTfe6DCWl5enpqYmZWZmdvrcq666Stddd51KSko6HX/44YcVExOjmpqaTo+Rnp4uSRo4cOB5XyMmJkYej0fz58/X4sWLO4wXFhbqqquuUktLS6fHSExMlCTdcMMN+sY3vtHpa+Tl5UnSBa8DgMvHZdu2He4mAAAAIh0fzwEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABggNAEAABj4/wC6U5I5z1WYjAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.387 0.387 0.172 0.045 0.007 0.001 0.    0.    0.    0.   ]\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "np.random.seed(20200605)\n",
    "n = 9# 做某件事情的次数\n",
    "p = 0.1# 做某件事情成功的概率\n",
    "size = 50000\n",
    "x = np.random.binomial(n, p, size)\n",
    "'''或者使用binom.rvs\n",
    "#使用binom.rvs(n, p, size=1)函数模拟一个二项随机变量,可视化地表现概率\n",
    "y = stats.binom.rvs(n, p, size=size)#返回一个numpy.ndarray\n",
    "'''\n",
    "print(np.sum(x == 0) / size)  # 0.3897\n",
    "\n",
    "plt.hist(x)\n",
    "plt.xlabel('随机变量：成功次数')\n",
    "plt.ylabel('样本中出现的次数')\n",
    "plt.show()\n",
    "#它返回一个列表，列表中每个元素表示随机变量中对应值的概率\n",
    "s = stats.binom.pmf(range(10), n, p)\n",
    "print(np.around(s, 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 308,
   "id": "dd4e19d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.99263404008459e-25"
      ]
     },
     "execution_count": 308,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "O"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 309,
   "id": "d85f7e6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.1529215046068474e-22"
      ]
     },
     "execution_count": 309,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.08**20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 318,
   "id": "7e93bb4f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.11496915e-007 1.86151371e-006 1.54586573e-005 8.51346345e-005\n",
      " 3.49792303e-004 1.14366875e-003 3.09950805e-003 7.16159624e-003\n",
      " 1.44010359e-002 2.56018416e-002 4.07403219e-002 5.86145343e-002\n",
      " 7.68784834e-002 9.25627224e-002 1.02911350e-001 1.06192581e-001\n",
      " 1.02152646e-001 9.19635075e-002 7.77469266e-002 6.19128843e-002\n",
      " 4.65692565e-002 3.31673380e-002 2.24174498e-002 1.44081908e-002\n",
      " 8.82240667e-003 5.15535416e-003 2.87941185e-003 1.53939571e-003\n",
      " 7.88820783e-004 3.87905872e-004 1.83271470e-004 8.32818461e-005\n",
      " 3.64358077e-005 1.53616053e-005 6.24679092e-006 2.45215644e-006\n",
      " 9.29924059e-007 3.40935730e-007 1.20926861e-007 4.15222666e-008\n",
      " 1.38106669e-008 4.45221925e-009 1.39189463e-009 4.22212729e-010\n",
      " 1.24327464e-010 3.55564534e-011 9.88052674e-012 2.66893044e-012\n",
      " 7.01077743e-013 1.79157400e-013 4.45556665e-014 1.07875612e-014\n",
      " 2.54355540e-015 5.84245703e-016 1.30773193e-016 2.85323330e-017\n",
      " 6.06976648e-018 1.25932607e-018 2.54886087e-019 5.03385934e-020\n",
      " 9.70294627e-021 1.82578604e-021 3.35452975e-022 6.01917002e-023\n",
      " 1.05499040e-023 1.80653874e-024 3.02279868e-025 4.94318798e-026\n",
      " 7.90151532e-027 1.23476736e-027 1.88666317e-028 2.81901907e-029\n",
      " 4.11958100e-030 5.88862085e-031 8.23438168e-032 1.12655889e-032\n",
      " 1.50809370e-033 1.97559423e-034 2.53281312e-035 3.17821349e-036\n",
      " 3.90367527e-037 4.69362995e-038 5.52484544e-039 6.36702984e-040\n",
      " 7.18432973e-041 7.93767377e-042 8.58777648e-043 9.09849382e-044\n",
      " 9.44013687e-045 9.59232276e-046 9.54598303e-047 9.30425484e-048\n",
      " 8.88213364e-049 8.30494029e-050 7.60581951e-051 6.82261155e-052\n",
      " 5.99450471e-053 5.15887452e-054 4.34865199e-055 3.59045487e-056\n",
      " 2.90358524e-057 2.29986950e-058 1.78421248e-059 1.35567010e-060\n",
      " 1.00881805e-061 7.35204875e-063 5.24715538e-064 3.66725203e-065\n",
      " 2.50979407e-066 1.68187237e-067 1.10352100e-068 7.08881489e-070\n",
      " 4.45802800e-071 2.74445741e-072 1.65379203e-073 9.75393409e-075\n",
      " 5.63008190e-076 3.18012801e-077 1.75762418e-078 9.50414243e-080\n",
      " 5.02755360e-081 2.60139317e-082 1.31645699e-083 6.51481011e-085\n",
      " 3.15232747e-086 1.49118795e-087 6.89507196e-089 3.11588326e-090\n",
      " 1.37589954e-091 5.93579847e-093 2.50137327e-094 1.02944004e-095\n",
      " 4.13674853e-097 1.62278465e-098 6.21312746e-100 2.32116839e-101\n",
      " 8.45950117e-103 3.00686808e-104 1.04207778e-105 3.52031281e-107\n",
      " 1.15886074e-108 3.71635883e-110 1.16065095e-111 3.52888705e-113\n",
      " 1.04417552e-114 3.00572263e-116 8.41387513e-118 2.28948983e-119\n",
      " 6.05329274e-121 1.55439090e-122 3.87471355e-124 9.37160777e-126\n",
      " 2.19814599e-127 4.99720600e-129 1.10045756e-130 2.34599648e-132\n",
      " 4.83845428e-134 9.64743030e-136 1.85833825e-137 3.45548267e-139\n",
      " 6.19733305e-141 1.07110266e-142 1.78229643e-144 2.85243493e-146\n",
      " 4.38603463e-148 6.47214596e-150 9.15389947e-152 1.23926783e-153\n",
      " 1.60360744e-155 1.98027160e-157 2.32973129e-159 2.60636097e-161\n",
      " 2.76711731e-163 2.78172134e-165 2.64131462e-167 2.36241804e-169\n",
      " 1.98424440e-171 1.55971066e-173 1.14292427e-175 7.77310655e-178\n",
      " 4.88166112e-180 2.81431340e-182 1.47909448e-184 7.02824650e-187\n",
      " 2.98932980e-189 1.12407231e-191 3.67859101e-194 1.02634485e-196\n",
      " 2.37360049e-199 4.36825487e-202 5.99760394e-205 5.46105526e-208\n",
      " 2.47330401e-211]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAGdCAYAAAA44ojeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjU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x5uGDRuawsJCY4wxkydPNg8//HBw/KWvxT311FNm//79ZuHChVW+FvfJJ5+YqKgoM3PmTHPgwAEzc+bMOvsVrqvhxJr+4Q9/MLGxsebtt982RUVFwa2srOyaX19tcGJNv+779i0eJ9b0yJEj5gc/+IF58sknzcGDB837779vmjZtap599tlrfn21wYk1nTZtmomLizNvvvmmOXz4sFm/fr1p1aqVGTx48DW/vtpQ0zU1xphdu3aZXbt2mfT0dDNs2DCza9cus2/fvuDxSHqNiuhAMcaYl19+2aSmpprY2FjToUMHs2nTpuCxESNGmB49eoSMz8vLM7fffruJjY01zZs3N/Pnz69yzrfeesvcfPPNJiYmxrRp08a88847Tl+GVcK9pqmpqUZSlW3atGnX4Grs4MTP6f/6vgWKMc6s6datW02nTp2M2+02LVu2NM8995w5f/6805dijXCvaWVlpZk+fbpp1aqVqVevnvH5fOaJJ54wp06dugZXY4earml1/65MTU0NGRMpr1EuYyL8PhoAAKhzIvYzKAAAoO4iUAAAgHUIFAAAYB0CBQAAWIdAAQAA1iFQAACAdQgUAABgHQIFAABYh0ABAADWIVAAAIB1CBQAAGAdAgUAAFjn/wETmMavTqvQ2AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "p = 0.08\n",
    "n = 192\n",
    "s = stats.binom.pmf(range(n + 1), n, p)\n",
    "print(s)\n",
    "plt.hist(s)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 319,
   "id": "818d80e5",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3028522735.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\Administrator\\AppData\\Local\\Temp\\ipykernel_66188\\3028522735.py\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    id\tdevice_id\tgender\tage\tuniversity\tgpa\tactive_days_within_30\u001b[0m\n\u001b[1;37m      \t^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "id\tdevice_id\tgender\tage\tuniversity\tgpa\tactive_days_within_30\n",
    "question_cnt\n",
    "answer_cnt\n",
    "1\t2138\tmale\t21\t北京大学\t3.4\t7\t2\t12\n",
    "2\t3214\tmale\t\n",
    "复旦大学\t4.0\t15\t5\t25\n",
    "3\t6543\tfemale\t20\t北京大学\t3.2\t12\t3\t30\n",
    "4\t2315\tfemale\t23\t浙江大学\t3.6\t5\t1\t2\n",
    "5\t5432\tmale\t25\t山东大学\t3.8\t20\t15\t70\n",
    "6\t2131\tmale\t28\t山东大学\t3.3\t15\t7\t13\n",
    "7\t4321\tmale\t26\t复旦大学\t3.6\t9\t6\t52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69e455b2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 367,
   "id": "fcf213c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>gender</th>\n",
       "      <th>university</th>\n",
       "      <th>active_days_within_30</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>male</td>\n",
       "      <td>b</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>male</td>\n",
       "      <td>f</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>female</td>\n",
       "      <td>b</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>female</td>\n",
       "      <td>z</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>male</td>\n",
       "      <td>s</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>male</td>\n",
       "      <td>s</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>male</td>\n",
       "      <td>f</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  gender university  active_days_within_30\n",
       "0   1    male          b                      7\n",
       "1   2    male          f                     15\n",
       "2   3  female          b                     12\n",
       "3   4  female          z                      5\n",
       "4   5    male          s                     20\n",
       "5   6    male          s                     15\n",
       "6   7    male          f                      9"
      ]
     },
     "execution_count": 367,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "df = pd.DataFrame({'id':[1,2,3,4,5,6,7], \n",
    "                   'gender':['male', 'male', 'female', 'female', 'male', 'male', 'male'],\n",
    "                   'university':['b', 'f', 'b', 'z', 's','s', 'f'],\n",
    "                  'active_days_within_30':[7,15,12,5,20,15,9]}, index=None)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 398,
   "id": "47af701e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   gender university       id active_days_within_30\n",
      "                     id_count                     c\n",
      "0  female          b        1                  12.0\n",
      "1  female          z        1                   5.0\n",
      "2    male          b        1                   7.0\n",
      "3    male          f        2                  12.0\n",
      "4    male          s        2                  17.5\n",
      "  university  count  mean\n",
      "0          b      1  12.0\n",
      "1          z      1   5.0\n",
      "2          b      1   7.0\n",
      "3          f      2  12.0\n",
      "4          s      2  17.5\n",
      "RangeIndex(start=0, stop=5, step=1)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gender</th>\n",
       "      <th>university</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>female</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>12.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>female</td>\n",
       "      <td>z</td>\n",
       "      <td>1</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>male</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>male</td>\n",
       "      <td>f</td>\n",
       "      <td>2</td>\n",
       "      <td>12.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>male</td>\n",
       "      <td>s</td>\n",
       "      <td>2</td>\n",
       "      <td>17.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gender university  count  mean\n",
       "0  female          b      1  12.0\n",
       "1  female          z      1   5.0\n",
       "2    male          b      1   7.0\n",
       "3    male          f      2  12.0\n",
       "4    male          s      2  17.5"
      ]
     },
     "execution_count": 398,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df2 = df.groupby(['gender', 'university'])['id','active_days_within_30'].agg(['count','mean']).reset_index()\n",
    "\n",
    "df2 = df.groupby(['gender', 'university']).agg({'id':[('id_count','count')], 'active_days_within_30':[('c', 'mean')]}).reset_index()\n",
    "print(df2)\n",
    "df2.columns = ['gender', 'university', 'count', 'mean']\n",
    "print(df2.iloc[:,1:])\n",
    "df2.set_index('gender')\n",
    "print(df2.index)\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 399,
   "id": "c047ca96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ True, False, False, ..., False,  True, False])"
      ]
     },
     "execution_count": 399,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.logical_or(x < 1, x > 3)\n",
    "\n",
    "\n",
    "\n",
    "q\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 405,
   "id": "504a19e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 9 25  4]\n",
      " [ 8 24 16]\n",
      " [17 11 21]\n",
      " [ 3 22  3]\n",
      " [ 3 15  3]\n",
      " [18 17 25]\n",
      " [16  5 12]\n",
      " [29 27 17]]\n",
      "[[ 8  5  3]\n",
      " [ 3 11  3]\n",
      " [ 3 15  4]\n",
      " [ 9 17 12]\n",
      " [16 22 16]\n",
      " [17 24 17]\n",
      " [18 25 21]\n",
      " [29 27 25]]\n",
      "[17 24 17]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "np.random.seed(100)\n",
    "x = np.random.randint(1, 30, [8, 3])\n",
    "print(x)\n",
    "# [[ 9 25  4]\n",
    "#  [ 8 24 16]\n",
    "#  [17 11 21]\n",
    "#  [ 3 22  3]\n",
    "#  [ 3 15  3]\n",
    "#  [18 17 25]\n",
    "#  [16  5 12]\n",
    "#  [29 27 17]]\n",
    "z = np.partition(x, kth=-3, axis=0)\n",
    "print(z)\n",
    "print(z[-3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 406,
   "id": "dc9d2823",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>subject</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>张三</td>\n",
       "      <td>语文</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>张三</td>\n",
       "      <td>数学</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>张三</td>\n",
       "      <td>外语</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>李四</td>\n",
       "      <td>语文</td>\n",
       "      <td>87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>李四</td>\n",
       "      <td>数学</td>\n",
       "      <td>90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>李四</td>\n",
       "      <td>外语</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  name subject  score\n",
       "0   张三      语文     93\n",
       "1   张三      数学     88\n",
       "2   张三      外语     91\n",
       "3   李四      语文     87\n",
       "4   李四      数学     90\n",
       "5   李四      外语     77"
      ]
     },
     "execution_count": 406,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({\n",
    "    'name':['张三','张三','张三','李四','李四','李四'],\n",
    "    'subject':['语文', '数学', '外语','语文', '数学', '外语'],\n",
    "    'score':[93, 88, 91, 87, 90, 77]\n",
    "})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 430,
   "id": "b0acb579",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "subject  外语  数学  语文\n",
      "name               \n",
      "张三       91  88  93\n",
      "李四       77  90  87\n",
      "      english  math  chinese\n",
      "name                        \n",
      "张三         91    88       93\n",
      "李四         77    90       87\n",
      "      chinese  math  english\n",
      "name                        \n",
      "张三         93    88       91\n",
      "李四         87    90       77\n",
      "Index(['张三', '李四'], dtype='object', name='name')\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chinese</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张三</th>\n",
       "      <td>93</td>\n",
       "      <td>88</td>\n",
       "      <td>91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>李四</th>\n",
       "      <td>87</td>\n",
       "      <td>90</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      chinese  math  english\n",
       "name                        \n",
       "张三         93    88       91\n",
       "李四         87    90       77"
      ]
     },
     "execution_count": 430,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = df.pivot_table(index=['name'],columns='subject', values='score')\n",
    "df2.reset_index()\n",
    "print(df2)\n",
    "df2.columns = ['english', 'math', 'chinese']\n",
    "#df2.reset_index(drop=False, inplace=True)\n",
    "print(df2)\n",
    "df3= df2.iloc[:, ::-1]\n",
    "print(df3)\n",
    "print(df3.index)\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 431,
   "id": "259b85bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1,2,3,4]\n",
    "b=a[1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 432,
   "id": "02673154",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3]"
      ]
     },
     "execution_count": 432,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 435,
   "id": "5919d4ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4])"
      ]
     },
     "execution_count": 435,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array(a)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 436,
   "id": "b8e75dcd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 3])"
      ]
     },
     "execution_count": 436,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = a[1:3]\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 437,
   "id": "cee2cd80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 9, 3, 4])"
      ]
     },
     "execution_count": 437,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b[0]=9\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 433,
   "id": "172ac66d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4]"
      ]
     },
     "execution_count": 433,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b[0]=9\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 434,
   "id": "6be37f9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[9, 3]"
      ]
     },
     "execution_count": 434,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 438,
   "id": "77405448",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'E:\\\\python\\\\python数据分析实战'"
      ]
     },
     "execution_count": 438,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os \n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 531,
   "id": "baf9e56d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>device_id</th>\n",
       "      <th>gender</th>\n",
       "      <th>age</th>\n",
       "      <th>university</th>\n",
       "      <th>gpa</th>\n",
       "      <th>active_days_within_30</th>\n",
       "      <th>question_cnt</th>\n",
       "      <th>answer_cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2138</td>\n",
       "      <td>male</td>\n",
       "      <td>21.0</td>\n",
       "      <td>北京大学</td>\n",
       "      <td>3.4</td>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3214</td>\n",
       "      <td>male</td>\n",
       "      <td>NaN</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>4.0</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>6543</td>\n",
       "      <td>female</td>\n",
       "      <td>20.0</td>\n",
       "      <td>北京大学</td>\n",
       "      <td>3.2</td>\n",
       "      <td>12</td>\n",
       "      <td>3</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2315</td>\n",
       "      <td>female</td>\n",
       "      <td>23.0</td>\n",
       "      <td>浙江大学</td>\n",
       "      <td>3.6</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>5432</td>\n",
       "      <td>male</td>\n",
       "      <td>25.0</td>\n",
       "      <td>山东大学</td>\n",
       "      <td>3.8</td>\n",
       "      <td>20</td>\n",
       "      <td>15</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>2131</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>山东大学</td>\n",
       "      <td>3.3</td>\n",
       "      <td>15</td>\n",
       "      <td>7</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>4321</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  device_id  gender   age university  gpa  active_days_within_30  \\\n",
       "0   1       2138    male  21.0       北京大学  3.4                      7   \n",
       "1   2       3214    male   NaN       复旦大学  4.0                     15   \n",
       "2   3       6543  female  20.0       北京大学  3.2                     12   \n",
       "3   4       2315  female  23.0       浙江大学  3.6                      5   \n",
       "4   5       5432    male  25.0       山东大学  3.8                     20   \n",
       "5   6       2131    male  28.0       山东大学  3.3                     15   \n",
       "6   7       4321    male  28.0       复旦大学  3.6                      9   \n",
       "\n",
       "   question_cnt  answer_cnt  \n",
       "0             2          12  \n",
       "1             5          25  \n",
       "2             3          30  \n",
       "3             1           2  \n",
       "4            15          70  \n",
       "5             7          13  \n",
       "6             6          52  "
      ]
     },
     "execution_count": 531,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('../user_profile.xls')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 532,
   "id": "d244c45b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>device_id</th>\n",
       "      <th>question_id</th>\n",
       "      <th>result</th>\n",
       "      <th>date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2138</td>\n",
       "      <td>111</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-05-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3214</td>\n",
       "      <td>112</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-05-09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>3214</td>\n",
       "      <td>113</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-06-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>6543</td>\n",
       "      <td>111</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2315</td>\n",
       "      <td>115</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>2315</td>\n",
       "      <td>116</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>2315</td>\n",
       "      <td>117</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>3214</td>\n",
       "      <td>112</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-05-09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>3214</td>\n",
       "      <td>113</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>6543</td>\n",
       "      <td>111</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>2315</td>\n",
       "      <td>115</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>2315</td>\n",
       "      <td>116</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>2315</td>\n",
       "      <td>117</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>3214</td>\n",
       "      <td>112</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>3214</td>\n",
       "      <td>113</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>6543</td>\n",
       "      <td>111</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    id  device_id  question_id result       date\n",
       "0    1       2138          111  wrong 2021-05-03\n",
       "1    2       3214          112  wrong 2021-05-09\n",
       "2    3       3214          113  wrong 2021-06-15\n",
       "3    4       6543          111  right 2021-08-13\n",
       "4    5       2315          115  right 2021-08-13\n",
       "5    6       2315          116  right 2021-08-14\n",
       "6    7       2315          117  wrong 2021-08-15\n",
       "7    8       3214          112  right 2021-05-09\n",
       "8    9       3214          113  right 2021-08-15\n",
       "9   10       6543          111  right 2021-08-13\n",
       "10  11       2315          115  right 2021-08-13\n",
       "11  12       2315          116  right 2021-08-14\n",
       "12  13       2315          117  wrong 2021-08-15\n",
       "13  14       3214          112  wrong 2021-08-16\n",
       "14  15       3214          113  wrong 2021-08-18\n",
       "15  16       6543          111  right 2021-08-13"
      ]
     },
     "execution_count": 532,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.read_excel('../question_practice_detail.xls')\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "980bccaa",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 586,
   "id": "d0af0f0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_x</th>\n",
       "      <th>device_id</th>\n",
       "      <th>gender</th>\n",
       "      <th>age</th>\n",
       "      <th>university</th>\n",
       "      <th>gpa</th>\n",
       "      <th>active_days_within_30</th>\n",
       "      <th>question_cnt</th>\n",
       "      <th>answer_cnt</th>\n",
       "      <th>id_y</th>\n",
       "      <th>question_id</th>\n",
       "      <th>result</th>\n",
       "      <th>date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>3214</td>\n",
       "      <td>male</td>\n",
       "      <td>NaN</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>4.0</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "      <td>9.0</td>\n",
       "      <td>113.0</td>\n",
       "      <td>right</td>\n",
       "      <td>2021-08-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>3214</td>\n",
       "      <td>male</td>\n",
       "      <td>NaN</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>4.0</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "      <td>14.0</td>\n",
       "      <td>112.0</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>3214</td>\n",
       "      <td>male</td>\n",
       "      <td>NaN</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>4.0</td>\n",
       "      <td>15</td>\n",
       "      <td>5</td>\n",
       "      <td>25</td>\n",
       "      <td>15.0</td>\n",
       "      <td>113.0</td>\n",
       "      <td>wrong</td>\n",
       "      <td>2021-08-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>7</td>\n",
       "      <td>4321</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>复旦大学</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>52</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    id_x  device_id gender   age university  gpa  active_days_within_30  \\\n",
       "4      2       3214   male   NaN       复旦大学  4.0                     15   \n",
       "5      2       3214   male   NaN       复旦大学  4.0                     15   \n",
       "6      2       3214   male   NaN       复旦大学  4.0                     15   \n",
       "18     7       4321   male  28.0       复旦大学  3.6                      9   \n",
       "\n",
       "    question_cnt  answer_cnt  id_y  question_id result       date  \n",
       "4              5          25   9.0        113.0  right 2021-08-15  \n",
       "5              5          25  14.0        112.0  wrong 2021-08-16  \n",
       "6              5          25  15.0        113.0  wrong 2021-08-18  \n",
       "18             6          52   NaN          NaN    NaN        NaT  "
      ]
     },
     "execution_count": 586,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3 = pd.merge(df,df2, on='device_id', how='left')[(df3.university=='复旦大学')&((df3.date.dt.month==8)|(df3.result.isnull()))]\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 609,
   "id": "16319254",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    id_x  device_id gender   age university  gpa  active_days_within_30  \\\n",
      "4      2       3214   male   NaN       复旦大学  4.0                     15   \n",
      "5      2       3214   male   NaN       复旦大学  4.0                     15   \n",
      "6      2       3214   male   NaN       复旦大学  4.0                     15   \n",
      "18     7       4321   male  28.0       复旦大学  3.6                      9   \n",
      "\n",
      "    question_cnt  answer_cnt  id_y  question_id result       date  \n",
      "4              5          25   9.0        113.0  right 2021-08-15  \n",
      "5              5          25  14.0        112.0  wrong 2021-08-16  \n",
      "6              5          25  15.0        113.0  wrong 2021-08-18  \n",
      "18             6          52   NaN          NaN    NaN        NaT  \n",
      "Int64Index([3214, 4321], dtype='int64', name='device_id')\n",
      "Index(['复旦大学', '复旦大学'], dtype='object', name='university')\n",
      "False\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>question_id</th>\n",
       "      <th>right_question_cnt</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>university</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>复旦大学</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>复旦大学</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            question_id  right_question_cnt\n",
       "university                                 \n",
       "复旦大学                  3                   1\n",
       "复旦大学                  0                   0"
      ]
     },
     "execution_count": 609,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df4 = df3\n",
    "print(df4)\n",
    "m = 2\n",
    "sum_2 = 0\n",
    "\n",
    "def cr(x):\n",
    "    return list(x).count('right')\n",
    "df5 = df4.groupby(['device_id']).agg({\n",
    "    'university': 'min',\n",
    "    'question_id': 'count',\n",
    "    'result':cr\n",
    "})\n",
    "df5['right_question_cnt'] = df5.result\n",
    "#df5 = df5.iloc[:, [0,1,3]]\n",
    "df5=df5.drop(['result'], axis=1)\n",
    "print(df5.index)\n",
    "df5 = df5.set_index('university')\n",
    "print(df5.index)\n",
    "print(df5.index.is_numeric())\n",
    "df5\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 611,
   "id": "e9b6a3fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['复旦大学', '复旦大学'], dtype=object)"
      ]
     },
     "execution_count": 611,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df5 = df5.reset_index()\n",
    "df5['university'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c601fee",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
